#include "Extrapolation.h"


using namespace std;

Extrapolation::Extrapolation(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(InitFirstTest()));
}

void Extrapolation::InitFirstTest()
{

	
	VectorXd Mesured(4);

	QString str1 = ui.lineEdit->text();
	QString str2 = ui.lineEdit_2->text();
	QString str3 = ui.lineEdit_3->text();
	QString str4 = ui.lineEdit_4->text();
	QString str5 = ui.lineEdit_5->text();
	double Mesured1 = str1.toDouble();
	double Mesured2 = str2.toDouble();
	double Mesured3 = str3.toDouble();
	double Mesured4 = str4.toDouble();
	float Tt = str5.toFloat();
	Mesured << Mesured1, Mesured2, Mesured3, Mesured4;

	test1.PathPrediction(Mesured, Tt);
	
	list<float>::iterator AzimuthSpliPre;
	list<float>::iterator ElevationSpliPre;
	list<float>::iterator SlopPre;
	//list<double>::iterator AzimuthSpePre;
	//list<double>::iterator ElevationSpePre;

	if (test1.AzimuthSpliPrediction.empty()!=true)
	{
		AzimuthSpliPre = test1.AzimuthSpliPrediction.begin();
		ElevationSpliPre = test1.ElevationSpliPrediction.begin();
		SlopPre = test1.SlopSpliPrediction.begin();
		//AzimuthSpePre = test1.AzimuthSpeePrediction.begin();
		//ElevationSpePre = test1.ElevationSpePrediction.begin();


		int cishu = 0;
		while ((AzimuthSpliPre != test1.AzimuthSpliPrediction.end()))
		{
			double PositonAziData = *AzimuthSpliPre++;
			double PositonEleData = *ElevationSpliPre++;
			double PositionSlopData = *SlopPre++;
			//double SpeedAziData = *AzimuthSpePre++;
			//double SpeedEleData = *ElevationSpePre++;

			QString datagram;
			cishu++;
			QString str2 = QString::number(cishu);
			ui.textBrowser->insertPlainText(str2);

			datagram = "Azi=" + QString("%1").arg(PositonAziData) + " ";
			ui.textBrowser->insertPlainText(datagram);

			datagram = "Ezi=" + QString("%1").arg(PositonEleData) + " ";
			ui.textBrowser->insertPlainText(datagram);

			datagram = "Slop=" + QString("%1").arg(PositionSlopData) + "\n ";
			ui.textBrowser->insertPlainText(datagram);

			//datagram = "AziSpe=" + QString("%1").arg(SpeedAziData) + " ";
			//ui.textBrowser->insertPlainText(datagram);

			//datagram = "EleSpe=" + QString("%1").arg(SpeedEleData) + "\n";
			//ui.textBrowser->insertPlainText(datagram);
		}
	}
	else
		ui.textBrowser->setText("not Init");
	

	
}